using System;
using System.Collections.Generic;
using System.Text;
using Barrage.GUI.Meshes;
using Barrage.GUI.Elements;
using System.Xml;
using SlimDX;
using Barrage.Textures;
using Barrage.Global;

namespace Barrage.GUI.Templates.Standard
{
    /// <summary>
    /// Standard template implementation of GUIImage
    /// </summary>
    public class StandardGUIImage:GUIImage
    {
         const string XML_TEXTURE_ATTRIBUTE = "texture";
         const string XML_WIDTH_ATTRIBUTE = "width";
         const string XML_HEIGHT_ATTRIBUTE = "height";
         const float DefaultHeight = 100;
         const float DefaultWidth = 100;
         Vector2 DefaultSize { get { return new Vector2(DefaultWidth, DefaultHeight); } }
        /// <summary>
        /// Constructor
        /// </summary>
         /// <param name="layout">Layout that will hold this item</param>
         /// <param name="xn">Xml Node that holds attribute values of this item</param>
         public StandardGUIImage(GUILayout layout, XmlNode xn)
            : base(layout,GUITemplateTypes.Standard,xn)
        {
            string texture=XmlHelper.GetXMLAttribute(xn,XML_TEXTURE_ATTRIBUTE);
            if (texture.Length == 0)
                texture = "Templates/Standard/image.png";
            addMesh(new SimpleRectangle(TextureManager.Textures[texture],GUIHelper.ParseVector2(XmlHelper.GetXMLAttribute(xn,XML_WIDTH_ATTRIBUTE),XmlHelper.GetXMLAttribute(xn,XML_HEIGHT_ATTRIBUTE),DefaultSize)));
        }

    }
}
